/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jfonia.actions;

import java.util.HashMap;
import javax.swing.AbstractAction;
import org.jfonia.images.ImageConstants;

/**
 *
 * @author Rik Bauwens
 */
public class ActionFactory
{
        private static ActionFactory instance;

        public final static String CLEARACTION = "clearaction";
        public final static String COPYACTION = "copyaction";
        public final static String CREATECHORDPARTACTION = "createchordpartaction";
        public final static String CREATELYRICPARTSACTION = "createlyricspartaction";
        public final static String CREATESTAFFPARTACTION = "createstaffpartaction";
        public final static String CUTACTION = "cutaction";
        public final static String ERRORCONSOLEACTION = "errorconsoleaction";
        public final static String HELPACTION = "helpaction";
        public final static String NEWACTION = "newaction";
        public final static String NEWPARTACTION = "newpartaction";
        public final static String NOTATIONMODEACTION = "notationmodeaction";
        public final static String OPENACTION = "openaction";
        public final static String PASTEACTION = "pasteaction";
        public final static String PERFORMANCEMODEACTION = "performancemodeaction";
        public final static String PLAYORPAUSEACTION = "playorpauseaction";
        public final static String REDOACTION = "redoaction";
        public final static String REMOVEACTION = "removeaction";
        public final static String RESOURCESACTION = "resourcesaction";
        public final static String SAVEACTION = "saveaction";
        public final static String SAVEASACTION = "saveasaction";
        public final static String STOPACTION = "stopaction";
        public final static String TAPPINGACTION = "tappingaction";
        public final static String UNDOACTION = "undoaction";

        private HashMap<String, AbstractAction> actions;

        private ActionFactory()
        {
                actions = new HashMap<String, AbstractAction>();
                //Initialise actions
                init();
        }

        private void init()
        {
                actions.put(CLEARACTION, new ClearAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(COPYACTION, new CopyAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(CREATECHORDPARTACTION, new CreateChordPartAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(CREATELYRICPARTSACTION, new CreateLyricsPartAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(CREATESTAFFPARTACTION, new CreateStaffPartAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(CUTACTION, new CutAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(ERRORCONSOLEACTION, new ErrorConsoleAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(HELPACTION, new HelpAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(NEWACTION, new NewAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(NEWPARTACTION, new NewPartAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(NOTATIONMODEACTION, new NotationModeAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(OPENACTION, new OpenAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(PASTEACTION, new PasteAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(PERFORMANCEMODEACTION, new PerformanceModeAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(PLAYORPAUSEACTION, new PlayOrPauseAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(REDOACTION, new RedoAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(REMOVEACTION, new RemoveAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(RESOURCESACTION, new ResourcesAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(SAVEACTION, new SaveAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(SAVEASACTION, new SaveAsAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(STOPACTION, new StopAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(TAPPINGACTION, new TappingAction(ImageConstants.LARGE_ICON_SIZE));
                actions.put(UNDOACTION, new UndoAction(ImageConstants.LARGE_ICON_SIZE));
        }

        public static synchronized ActionFactory getInstance()
        {
                if(instance == null)
                        instance = new ActionFactory();
                return instance;
        }

        public AbstractAction getAction(String action)
        {
                return actions.get(action);
        }


}
